# 调用
import PySimpleGUI as sg

from view import Student


def main():
    lst = ['1.查看学生信息', '2.根据编号查找学生', '3.添加学生信息', '4.根据编号删除学生', '5.修改学生信息', '6.退出']
    layout = [
        [sg.Text('学生信息管理系统', size=(20, 2), justification='center', font=('宋体', 18), text_color='red')]
        , [sg.Button(lst[0], size=(30, 2), key='-B1-')]
        , [sg.Button(lst[1], size=(30, 2), key='-B2-')]
        , [sg.Button(lst[2], size=(30, 2), key='-B3-')]
        , [sg.Button(lst[3], size=(30, 2), key='-B4-')]
        , [sg.Button(lst[4], size=(30, 2), key='-B5-')]
        , [sg.Button(lst[5], size=(30, 2), key='-B6-')]
    ]
    window_main = sg.Window('学生管理系统', layout)
    while True:
        event, values = window_main.read()
        # print(event, values)
        if event == None:
            break
        if event == '-B1-':
            window_main.close()
            Student.getAllStudents()
        if event == '-B2-':
            window_main.close()
            Student.getProduct()
        if event == '-B3-':
            window_main.close()
            Student.addStudent()
        if event == '-B4-':
            window_main.close()
            Student.deleteStudentById()
        if event == '-B5-':
            window_main.close()
            Student.updateStudentByNum()
        if event == '-B6-':
            window_main.close()
            break
        else:
            window_main.close()


if __name__ == '__main__':
    Student.login()
# market.reg()
# main()
